<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户管理</title>
<link href="../css/mq.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../scripts/jquery-1.4.2.src.js"></script>
<script language="javascript" type="text/javascript">	
	function GetFocus(){   
		if(event.keyCode==13)   
		{ 
		document.getElementById("sear").click();   
		return false;   
		}  
	} 
	function add(){
		window.location.href = "addUser.do";
	}	
	function search(){
		window.location.href = "getSearchProblemList.do?keyWordBack="+document.getElementById("keyWordBack").value;
	}
	function edit(id){
		url = "modifyUser.do?scId1=" + id;
		window.location.href = url;
	}
	function del(){
		document.userform.action = "deleteUser.do";
		document.userform.submit();
	}
	
	function checkDel(){
		var checkboxs = document.getElementsByName("chb");
		for(var i=0;i<checkboxs.length;i++)
	    {
	      if(checkboxs[i].checked){
	      	  if(confirm("确定要删除选中记录么?")){
					document.userform.action = "deleteUser.do";
					document.userform.submit();		
					return false; 
	      	  }else{
	      	  		return false; 
	      	  }
	      }
	    }
	    alert("请至少选择一项需要删除的条目!");
	    return false;  
    }
    
    function Del(id){
      var delurl;
	  if(confirm("确定要删除选中记录么?")){
	    delurl = 'deleteUserSingle.do?id='+id;
	  	location.href=delurl;
	  }else{
	    return false;
	  }
	}
	function resetPassword(form){
	$.ajax({
      url: 'resetUserPassword.do',
      type: 'GET',
      data: {
        pid: form.id
      },
      error: function(xhr) {
        alert('密码重置出错');
      },
      success: function(response) {
          alert(response);
      }
    });
 }
</script>
</head>

<body>

<div id="write">
<s:form name="userform" action="getUserList" method="post">
	<h4>用户管理</h4>
    <div style = "float:left;width:320px;margin:8px 10px 5px 0px;">
   	  <input name="添加用户" type="button" value="添加用户" class="buttonstyle-4word" onclick = "add()"/>
   	  <input name="删  除" type="button" value="删  除" class="buttonstyle-2word" onclick = "checkDel()"/>
    </div>
    <table width="99%" border="0" cellspacing="1" cellpadding="2" class="TableStyle">

  <tr class="TrTitleBg-2">
  	<td width=5% align = "center">&nbsp;</td>
    <td width=5% align = "center">序号</td>
    <td width=10% align = "center">用户名</td>
    <td width=10% align = "center">新郎名</td>
    <td width=10% align = "center">新娘名</td>
    <td width=10% align = "center">联系电话</td>
    <td width=10% align = "center">email</td>
    <td width=10% align = "center">省</td>
    <td width=10% align = "center">市</td>
    <td width=15% align = "center">操作</td>
  </tr>
  
  <s:iterator value="users" id="st" status="sr">
   <tr class="TrWhiteBg"> 
    <td width=5% align = "center">
	    <label>
      		<input type="checkbox" name="chb" id="adu" value = '<s:property value="id"/>'/>
      		
    	</label>
	</td>
	<td width=5% align = "center">
		${sr.count }
	</td>
	<td width=10% align = "center">
		<a href='modifyUser.do?id=<s:property value="id"/>'><s:property value="userName" /></a>
	</td>
	<td width=10% align = "center">
		<s:property value="husband" />
	</td>
	<td width=10% align = "center">
		<s:property value="wife" />
	</td>
	<td width=10% align = "center">
		<s:property value="mobile" />
	</td>
	<td width=10% align = "center">
		<s:property value="email" />
	</td>
	<td width=10% align = "center">
		<s:property value="province" />
	</td>
	<td width=10% align = "center">
		<s:property value="city" />
	</td>
	 <td width=10% align = "center">
		<a href='modifyUser.do?id=<s:property value="id"/>'>编辑</a>
		<a href="#" onclick="resetPassword(this)" id="${id }">重置密码</a>&nbsp;&nbsp;
		<a href="#" onclick = "Del(<s:property value="id"/>);return false;" >删除 </a>
	</td>
 </tr>
 </s:iterator>
 
</table>
	
</s:form>
</div>

</body>
</html>

